var common = {
    //成功弹出
    success: function (msg,url) {
        layer.msg(msg, {icon: 6,time: 1000},function(){
            window.location.href=url;
        });
    },
    //出错弹出
    error: function (msg) {
        layer.msg(msg, {icon: 5,time: 1000});
    },
    //改变状态
    status: function (url,id,objectState) {
        $.post(url,{id:id},function(data){
            if(data.status > 0){
                alert(data.msg);
            }else{
                if(data.data == 1){
                    objectState.removeClass('label-danger').addClass('label-primary').html('正常');
                }else{
                    objectState.removeClass('label-primary').addClass('label-danger').html('禁用');
                }
            }
        },'json');
    },
    //删除
    del: function (url,id,gotoUrl) {
        layer.msg('你确定要删除这家伙么？', {
            time: 0 //不自动关闭
            ,btn: ['必须啊', '放你一马']
            ,yes: function(index){
                $.post(url,{id:id},function(data){
                    if(data.status > 0){
                        common.error(data.msg);
                    }else{
                        common.success(data.msg,gotoUrl);
                    }
                },'json');
            }
        });
    }
}